# Maintainer: Andrew Leech <andrew@alelec.net>
# Contributor: Ray Donnelly <mingw.android@gmail.com>
# Contributor: Rocco Marco Guglielmi <guglielmir@playembedded.org>

_realname=openocd
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.10.0
pkgrel=2
pkgdesc="OpenOCD - Open On-Chip Debugger (mingw-w64)"
arch=('any')
url="http://openocd.org/"
license=("GPLv2")
options=('!ccache')
depends=("${MINGW_PACKAGE_PREFIX}-hidapi"
         "${MINGW_PACKAGE_PREFIX}-libusb"
         "${MINGW_PACKAGE_PREFIX}-libusb-compat"
         "${MINGW_PACKAGE_PREFIX}-libftdi"
         "${MINGW_PACKAGE_PREFIX}-libjaylink")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "${MINGW_PACKAGE_PREFIX}-pkg-config")
source=("https://downloads.sourceforge.net/sourceforge/${_realname}/${_realname}-${pkgver}.tar.bz2")
sha256sums=("7312e7d680752ac088b8b8f2b5ba3ff0d30e0a78139531847be4b75c101316ae")

build() {
  cd "${srcdir}"/${_realname}-${pkgver}

  ./configure \
      --prefix=${MINGW_PREFIX} \
      --{build,host}=${MINGW_CHOST} \
      --disable-dependency-tracking \
      --disable-werror \
      --disable-internal-libjaylink \
      --enable-dummy \
      --enable-jtag_vpi \
      --enable-remote-bitbang \
      --enable-amtjtagaccel \
      --enable-gw16012 \
      --enable-parport \
      --enable-parport-giveio

  make
}

package() {
  cd "${srcdir}"/${_realname}-${pkgver}
  make DESTDIR="${pkgdir}" install
  install -Dm644 COPYING ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING

  # bsdtar can't convert non-ascii filenames to UTF-8 when run in
  # non-UTF-8 locale. It proceeds to pack them anyway embedding raw
  # binary filenames in the traditional tar headers.
}
